<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>在线投票系统</title>
<link type="image/x-icon" href="images/yc.png" rel="shortcut icon" />
<title></title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript">
	window.onload = function() {
		var input = document.getElementById("loginBox").getElementsByTagName(
				"input");
		for (i = 0; i < input.length; i++) {
			var type = input[i].getAttribute("type");
			if (type == "text" || type == "password") {
				input[i].onfocus = function() {
					this.className += " input-text-over";
				}
				input[i].onblur = function() {
					this.className = this.className.replace(/input-text-over/,
							"");
				}
			} else if (type == "submit") {
				input[i].onmouseover = function() {
					this.className += " input-submit-over";
				}
				input[i].onmouseout = function() {
					this.className = this.className.replace(
							/input-button-over/, "");
				}
			}
		}
	}
</script>
</head>
<body>
	<div id="header" class="wrap">
		<img src="images/logo.gif" />
	</div>
	<div id="login" class="wrap">
		<div class="main">
			<div class="corner"></div>
			<div class="introduce">
				<h2>源辰信息</h2>
				<p>网上调查系统...</p>
			</div>
			<div class="login">
				<h2>用户登录</h2>
				<form onsubmit="return false">
					<dl id="loginBox">
						<dt>用户名：</dt>
						<dd><input type="text" class="input-text" v-model="uname" />
						</dd>
						<dt>密 码：</dt>
						<dd>
							<input type="password" class="input-text" v-model="pwd" />
						</dd>
						<dt></dt>
						<dd>
							<input type="submit" class="input-button" name="submit"
								value="登录"  @click="login"/> <a href="register.html">新用户注册</a>
						</dd>
					</dl>
				</form>
				<div class="error"></div>
			</div>
		</div>
	</div>
	<div class="wrap"></div>
	<div id="footer" class="wrap">源辰信息 &copy; 版权所有</div>
	
<script type="text/javascript" src="js/jquery-1.12.4.js"></script>
<script type="text/javascript" src="js/vue.js"></script>
<script type="text/javascript" src="js/qs.js"></script>
<script type="text/javascript" src="js/axios.js"></script>

<script type="text/javascript">
let app = new Vue({
	el: "#login",
	data:{
		uname:"",
		pwd:""
	},
	methods:{
		login:function(){
			if(this.uname == "" || this.pwd == "" ){
				return;
			}
			
			axios.post("user/login", qs.stringify({uname: this.uname, pwd: this.pwd})).then(rt =>{
				if(rt.status == 200 && rt.data.code == 200){
					location.href="manage.html";
					return;
				}
				alert("账号或密码错误...");
			})
		}
	}
	
})


</script>
</body>
</html>
